<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/7/17
 * Time: 16:44
 * Project name: PHPTEST
 * File name: 4.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */

function getQueryString() {
	return isset( $_SERVER['QUERY_STRING'] ) ? $_SERVER['QUERY_STRING'] : '';
}

function getRequestType() {
	if ( isset( $_POST['_method'] ) ) {
		return strtoupper( $_POST['_method'] );
	} elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
		return strtoupper( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
	}

	return strtoupper( isset( $_SERVER['REQUEST_METHOD'] ) ? $_SERVER['REQUEST_METHOD'] : 'GET' );
}

function getIsAjaxRequest()
{
	return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';
}
echo getQueryString();
echo getRequestType();
echo getIsAjaxRequest();